--[[
	gSpeak
	Author: Adult

	GUI Code is really messy,
	so I won't clutter the
	cl_voice file

	TODO: CUSTOM ICONS!
]]--

local function openGSpeakMenu()

	local Frame = vgui.Create( "DFrame" )
		Frame:SetSize( 410, 440 )
		Frame:Center()
		Frame:SetTitle( "gSpeak" )
		Frame:MakePopup()
		Frame:ShowCloseButton( true )

	local Tree = vgui.Create( "DTree", Frame )
		Tree:SetPos( 5, 25 )
		Tree:SetPadding( 5 )
		Tree:SetSize( 400, 375 )

	-- todo: buttons 

	-- Most horrifically inefficient way to do this. ever.
	-- Will fix later. Only using super nests for debugging reasons
	local groups = voice.groups 
	local channels = voice.channels 
	for i=1,#groups do
		local g_node = Tree:AddNode( groups[i] )

		for id, data in pairs( channels ) do
			local c_node = g_node:AddNode( id )
			local m_node = c_node:AddNode( "Members" )

			local members = data.members 
			for j=1,#members do
				m_node:AddNode( members[j] )
				-- todo: custom icons
			end
		end
	end
end

concommand.Add( "gspeak_menu", openGSpeakMenu )